package com.sr.examination.main;

import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;

import com.sr.examination.R;

/**
 * Created by jiangzhongshan on 18/1/30.
 */

public class MenuModel implements MenuFragment.MenuListener {
    private MainActivity parent;
    private MenuFragment menuFragment;

    public MenuModel(MainActivity parent) {
        this.parent = parent;
        FragmentManager manager = parent.getSupportFragmentManager();
        FragmentTransaction transaction = manager.beginTransaction();
        menuFragment = new MenuFragment();
        menuFragment.setListener(this);
        transaction.replace(R.id.menuLayout, menuFragment);
        transaction.commitAllowingStateLoss();
    }

    @Override
    public void onCloseMenu() {
        parent.closeMenu();
    }

    @Override
    public void onOpenMenu() {
        parent.openMenu();
    }
}
